package com.example.jasonrpc.example;

//import com.example.jasonrpc.client.RpcClient;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class Client {
    public static void main(String[] args) throws RemoteException, NotBoundException {
        rmiLocalClientTest();
//        RpcClient client = new RpcClient();
//        CalcService calcService = client.getProxy(CalcService.class);
//        StringService stringService = client.getProxy(StringService.class);
//        System.out.println(calcService.add(2, 3));
//        System.out.println(calcService.substract(20, 3));
//        System.out.println(stringService.greeting("天王盖地虎"));
//        System.out.println(stringService.greeting("Hello"));
//        System.out.println(stringService.greeting("hi"));
    }

    private static void rmiLocalClientTest() throws RemoteException, NotBoundException {
        Registry registry = LocateRegistry.getRegistry("127.0.0.1", 9999);
        CalcService calcService = (CalcService) registry.lookup("CalcService");
        int addRes = calcService.add(2, 3);
        System.out.println(addRes);
    }
}
